const { sequelize, DataTypes } = require('../utill/getSequelize')


const T_exam_target_to_question = sequelize.define('T_exam_target_to_question', {

    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
    },

    questionType: {
        type: DataTypes.STRING,
        defaultValue: "单项选择题"
    },

    questionNum: {
        type: DataTypes.INTEGER,
        defaultValue: 1
    },

    score: {
        type: DataTypes.INTEGER,
        defaultValue: 5
    },

    t_user_and_a_c_s_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },

    paperInfoId: {
        type: DataTypes.INTEGER
    },

    subid: {
        type: DataTypes.INTEGER
    },

    paperType: {
        type: DataTypes.STRING,
        defaultValue: "A"
    },

    targetId: {
        type: DataTypes.INTEGER
    },


}, {
    underscored: true
});


const { T_exam_target } = require('./t_exam_target')
T_exam_target_to_question.belongsTo(T_exam_target, { foreignKey: 'targetId', as: 'target' });
//同步模型和数据库表
(async () => {
    try {
        await sequelize.sync({ force: false });
        console.log('All models were synchronized successfully.');
    } catch (error) {
        console.log(error);
    }

})();

//提供出去
module.exports = { T_exam_target_to_question };